<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\common\model;


/**
 * 用户应用余额模型
 */
class AppBalanceWithdrawal extends ModelBase
{

    protected $insert = ['create_time','serial_number'];

    /**
     * 连用户表
     */
    public function member(){
        return $this->belongsTo('Member','user_id','id');
    }





    /**
     * 流水号自动完成
     */
    public function setSerialNumberAttr()
    {

        return 'AW'.date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
    }


    /**
     * 获取状态信息内容
     */
    public function getStateHtmlAttr(){

        switch ($this->state){
            case 0:
                $html='<span class="el-tag el-tag--mini">待审核</span>';
                break;
            case 1:
                $html='<span class="el-tag el-tag--success">成功</span>';
                break;
            case 2:
                $html='<span class="el-tag el-tag--danger">审核不通过</span>';
                break;

        }
        return $html;
    }



    /**
     * 时间自动完成
     */
    public function setCreateTimeAttr($value)
    {

        return TIME_NOW;
    }

    /**
     * 时间自动完成
     */
    public function getCreateTimeAttr($value)
    {

        return date('Y-m-d H:i:s',$value);
    }

//    public function  getRemarkAttr($value){
//
//        $lang=isset($_REQUEST['lang'])?$_REQUEST['lang']:'';
//        return   baidu_translate($value,$lang);
//
//
//    }


}
